<template>
	<view class="container">
		<uni-list>
			<uni-list-item @click="toDetail(item.id)" v-for="item,index in list" :key="index" :title="item.name"
				:thumb="'http://localhost:8090/foodapp/images/'+ item.icon" thumbSize="lg"
				:rightText="'￥'+item.price+'元'" :clickable="true" :showArrow="true"></uni-list-item>
		</uni-list>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				"list": []
			}
		},
		methods: {
			loadfoodcf(){
				uniCloud.callFunction({
					name:'foodcf'
				}).then(res=>{
					console.log(res.result.data);
					this.list = res.result.data
				})
			},
			toDetail(item_id){
				uni.navigateTo({
					url:'../fooddatail/fooddatail?id='+ item_id
				})
			},
			getlist() {
				uni.request({
					url: 'http://localhost:8080/foodapp/food/list',
					method: 'POST',
					data: {},
					success: res => {
						// console.log(res.data);
						if (res.data.success === true) {
							this.list = res.data.data
						}
					},
					fail: (err) => {
						uni.showToast({
							title: '网络错误',
							icon: 'error'
						});
					},
					complete: () => {}
				});
			}
		},
		onLoad() {
			// this.getlist()
			this.loadfoodcf()
		},
	}
</script>

<style scoped>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>